home *** CD-ROM | disk | FTP | other *** search
- Path: alpha2.csd.uwm.edu!peterk
- From: peterk@alpha2.csd.uwm.edu (Peter J Kleczka)
- Newsgroups: comp.lang.c
- Subject: Weird Results with this code
- Date: 2 Apr 1996 06:44:20 GMT
- Organization: Information & Media Technologies, University of Wisconsin - Milwaukee
- I am trying to learn C and ran into a little snag.
- Distribution: world
- Message-ID: <4jqic4$jg7@uwm.edu>
- NNTP-Posting-Host: 129.89.169.2
-
- The program is supposed to display
- some digits leave them on the screen for a second or so
- and then erase them. The "bug" is that the program seems
- to jump to the timer-loop BEFORE it prints out the digits.
- Consequently the desired display/delay/erase sequence works
- in the wrong order: delay/display/erase.
-
- thanks in advance for your suggestions
- please respond via email: peterk@csd.uwm.edu
-
-
- /* Display and Erase */
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
-
- void main()
- {
- long now;
- char pause;
-
- now = clock();
- printf ("watch the screen carefully please \n");
- printf("I will print the message: \"123 disappear\"\n");
- printf("then after a short pause\n");
- printf("only the digits \"123\" will disappear\n");
- printf("press return when ready\n");
- scanf ("%c", &pause);
- printf ("123 disappear");
-
- for ( ; clock() - now < CLOCKS_PER_SEC ; ); /* the timer loop */
-
- printf ("\r");
- printf (" ");
-
- }
-